package com.tnr.service.serviceimpl;

import com.tnr.dao.EmployeeDao;
import com.tnr.dto.EmployeeDto;
import com.tnr.pojo.Employee;
import com.tnr.service.EmplyeeService;
import com.tnr.untils.MybatisUntil;
import com.tnr.untils.QueryAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional//事务性
public class EmplyeeServiceImpl implements EmplyeeService {
    @Autowired
    private EmployeeDao employeeDao;


    @Override
    public Map<String, Object> getEmployeeList(final EmployeeDto employeeDteo) {

        return MybatisUntil.GetPageData(employeeDteo, new QueryAction() {
            @Override
            public List<Employee> query() {
                return employeeDao.findEmployeeList(employeeDteo);
            }
        });
    }

    @Override
    public void removeEmployee(String... eids) {
        employeeDao.deleteEmplyeeByIds(eids);
    }

    @Override
    public void addEmployee(EmployeeDto employeeDto) {
        employeeDao.addEmployee(employeeDto);
    }

    @Override
    public void updEmployee(EmployeeDto employeeDto) {
        employeeDao.updEmployee(employeeDto);
    }
}